import xml.dom.minidom
from xml.dom.minidom import Node
from xml.dom.ext import PrettyPrint

from interpreter import *
from album import *
from title import *

class Client:
	def __init__(self, name, node):
		self.interpreters = []
		self.name = name
		self.parse(node)
	def parse(self, node):
		for i in node.getElementsByTagName("entry"):
			if i.getAttribute("type") != "song":
				continue
			interpret = Interpreter(i)
			album = Album(i)
			title = Title(i)

			album.addTitle(title)
			interpret.addAlbum(album)

			tmp = self.isExisting(interpret)
			if tmp == None:
				self.interpreters.append(interpret)
			else:
				tmp.addAlbum(album)

	def isExisting(self, interpret):
		for i in self.interpreters:
			if i.name == interpret.name:
				return i
		return None
